﻿using System;
using Up2Link.Core;

namespace Up2Link.Server
{
    /// <summary>
    /// 服务器端消息的封装
    /// 为每个消息添加一个客户端标记，用于辨识每个消息的来源
    /// </summary>
    /// <typeparam name="T">消息格式</typeparam>
    public class CMessagePack<T> where T : IMessage
    {
        /// <summary>
        /// 来源为服务器的消息
        /// </summary>
        public const Int32 FROM_SERVER = -1;

        /// <summary>
        /// 消息来源
        /// </summary>
        public Int32 index;

        /// <summary>
        /// 消息本体
        /// </summary>
        public T message;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message">消息</param>
        /// <param name="index">客户端标记</param>
        public CMessagePack(T message, Int32 index)
        {
            this.index = index;
            this.message = message;            
        }
    }
}
